package com.yanqu.road.server.cmd.activity.unionwar;

import com.yanqu.road.pb.activity.unionwar.CrossUnionWarProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.manger.activity.unionwar.UnionPhaseWarMgr;
import com.yanqu.road.server.manger.activity.unionwar.UnionWar;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = Protocol.S_CROSS_UNION_WAR_RESULT_SYNC_FORM_CROSS,desc = "跨服同步下发战斗结果(明细)")
public class UnionWarBattleDetailSyncCmdFromCross implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {

        CrossUnionWarProto.CrossUnionWarBattleResultSyncMsg syncMsg =  CrossUnionWarProto.CrossUnionWarBattleResultSyncMsg.parseFrom(packet.getBytes());
        UnionWar unionWar = UnionPhaseWarMgr.getUnionWarMap().get(syncMsg.getActivityId());
        if(unionWar != null) {
            for (CrossUnionWarProto.CrossUnionWarUnionBattleTempMsg temp : syncMsg.getUnionDataListList()) {
                unionWar.addCrossUnionWarBattleResult(syncMsg.getPhase(), syncMsg.getSession(), temp, syncMsg.getGroupId());
            }
        }
    }
}
